home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Go Sit In The Corner 1.0 / source / VBL code / gsitc VBL.c
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.3 KB  |  108 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        gsitc VBL.c
  4.  
  5. Purpose:    This module handles actually moving the mouse to the right
  6.             corner.
  7.                         
  8.  
  9. Go Sit In The Corner -=- not you, just the cursor
  10. Copyright ©1994, Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "Retrace.h"
  30.  
  31. extern Boolean CrsrNew : 0x8CE;
  32. extern Point mTemp : 0x828;
  33. extern Point RawMouse : 0x82C;
  34.  
  35. unsigned long    me;
  36. int                gOldX;
  37. int                gOldY;
  38. unsigned long    gStartTicks;
  39. unsigned char    gAlways;
  40. unsigned long    gTargetTicks;
  41. int                gTargetX;
  42. int                gTargetY;
  43. Boolean            gNeedNewCursor;
  44.  
  45. void header(void);
  46. void main(void);
  47.  
  48. void header(void)
  49. {
  50.     asm {
  51.         dc.l    0
  52.         move.l a0, d0
  53.         lea header, a0
  54.         jmp main
  55.     }
  56. }
  57.  
  58. #include "SetUpA4.h"
  59.  
  60. void main(void)
  61. {
  62.     VBLTask*        myVBL;
  63.     Boolean            needNewCursor;
  64.     
  65.     RememberA0();
  66.     SetUpA4();
  67.     
  68.     asm
  69.     {
  70.         move.l d0, myVBL
  71.     }
  72.     if (me != '©MSG')
  73.     {
  74.         me = '©MSG';
  75.         gTargetTicks=*((unsigned long*)((long)myVBL-8));
  76.         gTargetX=*((int*)((long)myVBL-4));
  77.         gTargetY=*((int*)((long)myVBL-2));
  78.         gAlways=*((unsigned char*)((long)myVBL-12));
  79.         gOldX=-1;
  80.         gOldY=-1;
  81.         gStartTicks=0L;
  82.         gNeedNewCursor=TRUE;
  83.     }
  84.     
  85.     needNewCursor=((RawMouse.h!=gOldX) || (RawMouse.v!=gOldY));
  86.     
  87.     if ((RawMouse.h!=gOldX) || (RawMouse.v!=gOldY))
  88.     {
  89.         gStartTicks=TickCount();
  90.         gOldX=RawMouse.h;
  91.         gOldY=RawMouse.v;
  92.         gNeedNewCursor=TRUE;
  93.     }
  94.     
  95.     if (TickCount()-gStartTicks>=gTargetTicks)
  96.     {
  97.         RawMouse.h=mTemp.h=gOldX=gTargetX;
  98.         RawMouse.v=mTemp.v=gOldY=gTargetY;
  99.         gStartTicks=TickCount();
  100.         if (gNeedNewCursor)
  101.             CrsrNew=TRUE;
  102.         gNeedNewCursor=FALSE;
  103.     }
  104.     
  105.     myVBL->vblCount = 1;
  106.     RestoreA4();
  107. }
  108.